package com.example.sport.ui.dashboard.recyclercalendar;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.sport.R;

import java.util.List;

/**
 * @ProjectName : RecyclerCalendar
 * @Author : Victor Scott
 * @Time : 2022/5/26 20:31
 * @Description : 描述
 */
public class CalendarAdapter extends RecyclerView.Adapter<CalendarAdapter.ViewHolder> {
    private List<Day> mDayList;

    public CalendarAdapter(List<Day> mDayList) {
        this.mDayList = mDayList;
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.calendar_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Day dayItem = mDayList.get(position);
        holder.day.setText(dayItem.getDay());
        holder.week.setText(dayItem.getWeek());
    }


    @Override
    public int getItemCount() {
        return mDayList.size();
    }


    public static class ViewHolder extends RecyclerView.ViewHolder{
        TextView week;
        TextView day;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            day = itemView.findViewById(R.id.day);
            week = itemView.findViewById(R.id.week);
        }
    }
}
